package com.vshop.utils.sequence;

public class SequenceHepler {
    /**
     * 根据当前值返回指定长度的字符串，长度不足时在左边补0 形如：prefix+"0..."+currentVal
     *
     * @param prefix     前缀
     * @param currentVal 当前值
     */
    public static String generateSequence(String prefix, String currentVal, int length) {
        int currentLen = 0;
        if (!StringHelper.isEmpty(currentVal)) {
            currentLen = currentVal.length();
        }
        StringBuffer addStr = new StringBuffer();
        if (currentLen < length) {
            for (int i = 0; i < length - currentLen; i++) {
                addStr.append("0");
            }
        }
        return prefix + addStr.toString() + currentVal;
    }
}
